import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:qgchat/widgets/Zego/ZegoFace.dart';
import 'package:qgchat/widgets/Zego/ZegoPreview.dart';

class Face extends StatefulWidget {
  Face({Key key}) : super(key: key);

  @override
  _FaceState createState() => _FaceState();
}

class _FaceState extends State<Face> {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Builder(
          builder: (context) {
            // 计算屏幕像素
            final width = MediaQuery.of(context).size.width.toInt();
            final height = MediaQuery.of(context).size.height.toInt();
            final ratio = MediaQuery.of(context).devicePixelRatio.toInt();
            final screenWidthPx = width * ratio;
            final screenHeightPx = height * ratio;
            return ZegoPreview(
              screenWidthPx: screenWidthPx,
              screenHeightPx: screenHeightPx,
            );
          },
        ),
        Scaffold(
          backgroundColor: Colors.transparent,
          floatingActionButton: CupertinoButton(
            child: Icon(
              Icons.settings,
              size: 40,
              color: Colors.white,
            ),
            onPressed: () {
              ZegoFace.instance.show(context);
            },
          ),
          appBar: AppBar(
            backgroundColor: Colors.transparent,
            elevation: 0,
          ),
        ),
      ],
    );
  }
}
